home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / byt87ibm.arc / SAGAN.ARC / MICROSOF.ASM < prev    next >
Assembly Source File  |  1987-06-03  |  3KB  |  102 lines

  1. ;
  2. MSDOS        EQU    21H    ; Ms dos interrupt call 
  3. MSYSCALL    EQU    51     ; Microsoft system call 
  4. ; This is the main entry point 
  5. ; all driver routines take the function call number in BX 
  6. ;     function 0 = initialize mouse 
  7. ;     function 1 = return button status 
  8. ;     function 2 = return relative motion 
  9. ;     function 3 = de-initialize mouse 
  10. ;     function 4 = return current serial port 
  11. ; Normally this would be a far procedure but to avoid getting into 
  12. ; all the intricasies of loading and calling drivers I've converted 
  13. ; ENTRY to a near procedure and combined it with the sample program. 
  14. ENTRY    PROC    NEAR  
  15.     CLD              ; go in the forward direction 
  16.     PUSH    DS        ; save callers segment 
  17.     PUSH    CS        ; make this segment addressable 
  18.     POP    DS 
  19.     SHL    BX,1        ; point to routine 
  20.     CALL    ROUTINES[BX]    ; and call it through table 
  21.     POP    DS        ; restore users segment 
  22.     RET            ; return far to caller 
  23. ENTRY    ENDP 
  24.     DB    'Microsoft',00    ; name 
  25. MOUSEF    DB    0 
  26. ROUTINES LABEL WORD 
  27.     DW    ISERIAL        ; function 0 = initialize mouse 
  28.     DW    BUTTONSTAT    ; function 1 = return button status 
  29.     DW    MOTIONCOUNT    ; function 2 = return relative motion 
  30.     DW    DSERIAL        ; function 3 = de-initialize mouse 
  31.     DW    GSERIAL        ; function 4 = return current serial port 
  32.     DW    RETADR        ; function 5 = reserved 
  33.     DW    RETADR        ; function 6 = reserved 
  34.     DW    RETADR        ; function 7 = reserved 
  35. BUTTONSTAT: 
  36.     SUB    AX,AX 
  37.     TEST    MOUSEF,0FFH    ; if no mouse then return zero 
  38.     JZ    BSTAT2 
  39.     MOV    AX,5         
  40.     SUB    BX,BX 
  41.     INT    MSYSCALL    ; Read button press info 
  42.     SUB    AH,AH        ; make ax contain press info 
  43. BSTAT2: 
  44. ; for Microsoft mouse the exit routine does nothing 
  45. DSERIAL: 
  46. RETADR: 
  47.     RET 
  48. ; This routine returns delta mouse movement 
  49. ;    Ax = delta x 
  50. ;    Bx = delta y 
  51. MOTIONCOUNT: 
  52.     SUB    AX,AX 
  53.     MOV    BX,AX 
  54.     TEST    MOUSEF,0FFH 
  55.     JZ    MCOUNT2 
  56.     PUSH    DX 
  57.     PUSH    CX 
  58.     MOV    AX,11 
  59.     INT    MSYSCALL 
  60.     MOV    AX,CX        ; place into appropriate 
  61.     MOV    BX,DX        ; registers 
  62.     POP    CX 
  63.     POP    DX 
  64. MCOUNT2: 
  65.     RET 
  66. GSERIAL: 
  67.     SUB    AX,AX        ; No serial port needed 
  68.     RET            ; for Microsoft Mouse     
  69. ISERIAL PROC    NEAR 
  70.     PUSH    ES 
  71.     PUSH    BX 
  72.     MOV    AX,03500h+MSYSCALL    ; 35h = get INTerrupt vector 
  73.     INT    MSDOS            ; returns in ES:BX 
  74.     MOV    AX,ES 
  75.     OR    AX,BX            ; Does interupt point at 0:0? 
  76.     MOV    AX,0            ; if it does then 
  77.     POP    BX            ; Mouse software is not loaded 
  78.     POP    ES            ; and therefore cannot be called 
  79.     JZ    SER2            ; to do initialization.  
  80.     INT    MSYSCALL 
  81. SER2: 
  82.     MOV    MOUSEF,AL 
  83.     RET                ; returns al non 0 if mouse exists. 
  84. ISERIAL    ENDP 
  85. ;
  86.